var addMenu = {
    init: function () {
        addMenu.powerObj = new Array();
    },
    /**
     * 缓存操作
     */
    cache: function () {

        return
    },
    loadData: function (data) {
        console.log("加载数据：", data);
        if (data.authority) {
            for (var i = 0, cnt = data.authority.length; i < cnt; i++) {
                if ($.trim(data.authority[i].url) != '') {
                    addMenu.addPower(data.authority[i]);
                }
            }
        }
    },
    /**
     * 父级菜单选择事件
     * @param val
     */
    selectSupperMenu: function (val, name) {
        $('#url').removeAttr('readonly');
        $('#icon').val('').attr('readonly', 'readonly');
    },
    supperNull: function () {
        common.setSelectVal('supper_menu_id', '');
        $('#url').val('').attr('readonly', 'readonly');
        $('#icon').removeAttr('readonly');
    },
    /**
     * 添加权限
     */
    addPower: function (data) {
        var html = '<tr>' +
            '	      <td>' +
            '	<input type="hidden" value="' + (data == undefined || data.id == undefined ? '0' : data.id) + '" msg="请填写权限名称" name="authorityid" id="authorityid" style="" autocomplete="off" placeholder="请填写权限名称 " class="layui-input">' +
            '	<input type="text" msg="请填写权限名称" name="authority" value="' + (data == undefined || data.name == undefined ? '' : data.name) + '" id="authority" style="" autocomplete="off" placeholder="请填写权限名称 " class="layui-input">' +
            '</td>' +
            '<td class="select2div">' +
            '<input id="authority_url" name="authority_url" value="' + (data == undefined || data.url == undefined ? '' : data.url) + '" class="layui-input" placeholder="请填写权限URL路径" >' +
            '</td>' +
            '<td style="text-align: center;" >' +
            '	<i class="layui-icon" onclick="return addMenu.delatePower(this,\'' + (data == undefined || data.id == undefined ? '' : data.id) + '\');" style="cursor: pointer;" ></i>' +
            '</td>' +
            '</tr>';
        $('tbody').append(html);
        return false;
    },
    /**
     * 删除权限
     * @param obj
     */
    delatePower: function (obj, power_id) {
        if (power_id != "") {
            $('#delete_power_id').val($('#delete_power_id').val() + power_id + ",");
        }
        //清除
        $(obj).parent().parent().remove();

        return false;
    }
}